

using System;
using System.IO; 
using System.Drawing; 
using System.Text.RegularExpressions; 
using Microsoft.Win32; 
using System.ComponentModel;
using System.Windows.Forms;
using System.Reflection;
using System.Collections;
using System.Collections.Specialized;
using System.Diagnostics;
using vXCopy.Properties;
using System.Runtime;
//
//using SSK.SSKClient.SSKForms;
//using SSK.SSKClient.UIHelper;
//using SSK.SSKClient.ClientStorage;


namespace vXCopy
{

	partial class AboutBox : Form
	{
		bool bAscending = false;

		private void BuyNowButton_Click(object sender, EventArgs e)
		{
			//try
			//{
			//    BuyNowForm buyMe = new BuyNowForm();
			//    buyMe.ShowDialog();
			//}
			//catch (DataStoreAppConfigException datStoreAppConfigException)
			//{
			//    //Form cannot be used until the datstore has been initialized.
			//}
		}

		private void RegisterButton_Click(object sender, EventArgs e)
		{
			//try
			//{
			//    RegisterForm register = new RegisterForm();
			//    register.ShowDialog();
			//}
			//catch (DataStoreAppConfigException datStoreAppConfigException)
			//{
			//    //Form cannot be used until the datstore has been initialized.
			//}
		}

		private void SubmitFeedbackButton_Click(object sender, EventArgs e)
		{
			//try
			//{
			//    FeedbackForm feedback = new FeedbackForm();
			//    feedback.ShowDialog();
			//}
			//catch (DataStoreAppConfigException datStoreAppConfigException)
			//{
			//    //Form cannot be used until the datstore has been initialized.
			//}
		}

		private void ErrorReportButton_Click(object sender, EventArgs e)
		{
			//string exceptionNullTest = null;
			//try
			//{
			//    //try and check the length without initializing the string to throw
			//    //an exception for testing
			//    if (exceptionNullTest.Length > 0)
			//    {

			//    }
			//}
			////catch the exception to display the exception form
			//catch (Exception ex)
			//{
			//    try
			//    {
			//        ExceptionForm exForm = new ExceptionForm(ex.Message,
			//                                     ex.Source,
			//                                     ex.StackTrace,
			//                                     "simulateExceptionButton_Click");
			//        exForm.ShowDialog(this);
			//    }
			//    catch (DataStoreAppConfigException datStoreAppConfigException)
			//    {
			//        //Form cannot be used until the datstore has been initialized.
			//    }
			//}
		}

		private void VerifyLicensingButton_Click(object sender, EventArgs e)
		{
			//DataStore ds = new DataStore(this);
			//string displayText;

			//displayText = "Product State: " + ds.GetProductState.ToString() + "\r\n\r\n\r\n";
			//displayText += "Product License Level: " + ds.GetLicenseLevel.LicenseLevel + " " + ds.GetLicenseLevel.LicenseLevelID.ToString() + "\r\n\r\n\r\n";
			//displayText += "Is User Registered: " + ds.UserRegistered.ToString() + "\r\n\r\n\r\n";
			//try
			//{
			//    displayText += "Trial Days Elapsed: " + ds.DaysElapsedSinceInstall.ToString() + "\r\n\r\n\r\n";
			//}
			//catch (DataStoreChronologyException ex)
			//{
			//    displayText += ex.Message;
			//}
			//MessageBox.Show(this, displayText);
		}

		public AboutBox()
		{
			InitializeComponent();

			Text = String.Format("About {0}", AssemblyTitle);

			AppTitle = String.Format("About {0}", AssemblyTitle);
			AppDescription = AssemblyDescription;
			AppVersion = AssemblyVersion;
			AppCopyright = AssemblyCopyright;

			AppMoreInfo += Environment.NewLine;
			AppMoreInfo += Environment.NewLine;
      AppMoreInfo += string.Format(@"http://www.vrxtools.com/vxcopy/Default.aspx{0}", Environment.NewLine);
			AppMoreInfo += string.Format(@"mailto:vrithner@hotmail.com?subject=vXCopy{0}", Environment.NewLine);
			AppDetailsButton = true;

			toolStrip1.Enabled = false;


		}

		private System.Windows.Forms.GroupBox GroupBox1;
		internal System.Windows.Forms.RichTextBox MoreRichTextBox;
		internal System.Windows.Forms.ListView AppInfoListView;
		internal System.Windows.Forms.ColumnHeader colKey;
		internal System.Windows.Forms.ColumnHeader colValue;
		internal System.Windows.Forms.ListView AssemblyInfoListView;
		internal System.Windows.Forms.ColumnHeader colAssemblyName;
		internal System.Windows.Forms.ColumnHeader colAssemblyVersion;
		internal System.Windows.Forms.ColumnHeader colAssemblyBuilt;
		internal System.Windows.Forms.ColumnHeader colAssemblyCodeBase;
		internal System.Windows.Forms.TabControl TabPanelDetails;
		internal System.Windows.Forms.TabPage TabPageApplication;
		internal System.Windows.Forms.TabPage TabPageAssemblies;
		internal System.Windows.Forms.TabPage TabPageAssemblyDetails;
		internal System.Windows.Forms.ListView AssemblyDetailsListView;
		internal System.Windows.Forms.ColumnHeader ColumnHeader1;
		internal System.Windows.Forms.ColumnHeader ColumnHeader2;
		internal System.Windows.Forms.ComboBox AssemblyNamesComboBox;
		private System.Windows.Forms.Button OKButton;
		private System.Windows.Forms.Label AppTitleLabel;
		private System.Windows.Forms.Label AppDescriptionLabel;
		private System.Windows.Forms.Label AppVersionLabel;
		private System.Windows.Forms.Label AppCopyrightLabel;
		private System.Windows.Forms.Button SysInfoButton;
		private System.Windows.Forms.Label AppDateLabel;
		private System.Windows.Forms.Button DetailsButton;

		private bool _IsPainted = false;
		private string _strEntryAssemblyName;
		private string _strCallingAssemblyName;
		private string _strExecutingAssemblyName;
		private System.Reflection.Assembly _EntryAssembly;
		private System.Collections.Specialized.NameValueCollection _EntryAssemblyAttribCollection;
		private int _intMinWindowHeight;

		public System.Reflection.Assembly AppEntryAssembly
		{
			get
			{
				return _EntryAssembly;
			}
			set
			{
				_EntryAssembly = value;
			}
		}

		public string AppTitle
		{
			get
			{
				return AppTitleLabel.Text;
			}
			set
			{
				AppTitleLabel.Text = value;
			}
		}

		public string AppDescription
		{
			get
			{
				return AppDescriptionLabel.Text;
			}
			set
			{
				if (value == "")
				{
					AppDescriptionLabel.Visible = false;
				}
				else
				{
					AppDescriptionLabel.Visible = true;
					AppDescriptionLabel.Text = value;
				}
			}
		}

		public string AppVersion
		{
			get
			{
				return AppVersionLabel.Text;
			}
			set
			{
				if (value == "")
				{
					AppVersionLabel.Visible = false;
				}
				else
				{
					AppVersionLabel.Visible = true;
					AppVersionLabel.Text = value;
				}
			}
		}

		public string AppCopyright
		{
			get
			{
				return AppCopyrightLabel.Text;
			}
			set
			{
				if (value == "")
				{
					AppCopyrightLabel.Visible = false;
				}
				else
				{
					AppCopyrightLabel.Visible = true;
					AppCopyrightLabel.Text = value;
				}
			}
		}

		public Image AppImage
		{
			get
			{
				return ImagePictureBox.Image;
			}
			set
			{
				ImagePictureBox.Image = value;
			}
		}

		public string AppMoreInfo
		{
			get
			{
				return MoreRichTextBox.Text;
			}
			set
			{
				if (value == "")
				{
					MoreRichTextBox.Visible = false;
				}
				else
				{
					MoreRichTextBox.Visible = true;
					MoreRichTextBox.Text = value;
				}
			}
		}

		public bool AppDetailsButton
		{
			get
			{
				return DetailsButton.Visible;
			}
			set
			{
				DetailsButton.Visible = value;
			}
		}

		private static DateTime AssemblyLastWriteTime(System.Reflection.Assembly a)
		{
			try
			{
				return File.GetLastWriteTime(a.Location);
			}
			catch (Exception)
			{
				return DateTime.MaxValue;
			}
		}

		private static DateTime AssemblyBuildDate(System.Reflection.Assembly a)
		{
			return AssemblyBuildDate(a, false);
		}

		private static DateTime AssemblyBuildDate(System.Reflection.Assembly a, bool ForceFileDate)
		{
			System.Version AssemblyVersion = a.GetName().Version;
			DateTime dt;
			if (ForceFileDate)
			{
				dt = AssemblyLastWriteTime(a);
			}
			else
			{
				DateTime _dt = new DateTime(05, 01, 01);
				dt = _dt.AddDays(AssemblyVersion.Build).AddSeconds(AssemblyVersion.Revision * 2);
				if (TimeZone.IsDaylightSavingTime(dt, TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year)))
				{
					dt = dt.AddHours(1);
				}
				if (dt > DateTime.Now | AssemblyVersion.Build < 730 | AssemblyVersion.Revision == 0)
				{
					dt = AssemblyLastWriteTime(a);
				}
			}
			return dt;
		}

		private System.Collections.Specialized.NameValueCollection AssemblyAttribs(System.Reflection.Assembly a)
		{
			string TypeName;
			string Name;
			string Value;
			System.Collections.Specialized.NameValueCollection nvc = new System.Collections.Specialized.NameValueCollection();
			Regex r = new Regex("(\\.Assembly|\\.)(?<Name>[^.]*)Attribute$", RegexOptions.IgnoreCase);
			foreach (object attrib in a.GetCustomAttributes(false))
			{
				TypeName = attrib.GetType().ToString();
				Name = r.Match(TypeName).Groups["Name"].ToString();
				Value = "";
				if (TypeName == "System.CLSCompliantAttribute")
				{
					Value = ((CLSCompliantAttribute)(attrib)).IsCompliant.ToString();
				}
				else if (TypeName == "System.Diagnostics.DebuggableAttribute")
				{
					Value = ((System.Diagnostics.DebuggableAttribute)(attrib)).IsJITTrackingEnabled.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyCompanyAttribute")
				{
					Value = ((AssemblyCompanyAttribute)(attrib)).Company.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyConfigurationAttribute")
				{
					Value = ((AssemblyConfigurationAttribute)(attrib)).Configuration.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyCopyrightAttribute")
				{
					Value = ((AssemblyCopyrightAttribute)(attrib)).Copyright.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyDefaultAliasAttribute")
				{
					Value = ((AssemblyDefaultAliasAttribute)(attrib)).DefaultAlias.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyDelaySignAttribute")
				{
					Value = ((AssemblyDelaySignAttribute)(attrib)).DelaySign.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyDescriptionAttribute")
				{
					Value = ((AssemblyDescriptionAttribute)(attrib)).Description.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyInformationalVersionAttribute")
				{
					Value = ((AssemblyInformationalVersionAttribute)(attrib)).InformationalVersion.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyKeyFileAttribute")
				{
					Value = ((AssemblyKeyFileAttribute)(attrib)).KeyFile.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyProductAttribute")
				{
					Value = ((AssemblyProductAttribute)(attrib)).Product.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyTrademarkAttribute")
				{
					Value = ((AssemblyTrademarkAttribute)(attrib)).Trademark.ToString();
				}
				else if (TypeName == "System.Reflection.AssemblyTitleAttribute")
				{
					Value = ((AssemblyTitleAttribute)(attrib)).Title.ToString();
				}
				else if (TypeName == "System.Resources.NeutralResourcesLanguageAttribute")
				{
					Value = ((System.Resources.NeutralResourcesLanguageAttribute)(attrib)).CultureName.ToString();
				}
				else if (TypeName == "System.Resources.SatelliteContractVersionAttribute")
				{
					Value = ((System.Resources.SatelliteContractVersionAttribute)(attrib)).Version.ToString();
				}
				else if (TypeName == "System.Runtime.InteropServices.ComCompatibleVersionAttribute")
				{
					System.Runtime.InteropServices.ComCompatibleVersionAttribute x;
					x = ((System.Runtime.InteropServices.ComCompatibleVersionAttribute)(attrib));
					Value = x.MajorVersion + "." + x.MinorVersion + "." + x.RevisionNumber + "." + x.BuildNumber;
				}
				else if (TypeName == "System.Runtime.InteropServices.ComVisibleAttribute")
				{
					Value = ((System.Runtime.InteropServices.ComVisibleAttribute)(attrib)).Value.ToString();
				}
				else if (TypeName == "System.Runtime.InteropServices.GuidAttribute")
				{
					Value = ((System.Runtime.InteropServices.GuidAttribute)(attrib)).Value.ToString();
				}
				else if (TypeName == "System.Runtime.InteropServices.TypeLibVersionAttribute")
				{
					System.Runtime.InteropServices.TypeLibVersionAttribute x;
					x = ((System.Runtime.InteropServices.TypeLibVersionAttribute)(attrib));
					Value = x.MajorVersion + "." + x.MinorVersion;
				}
				else if (TypeName == "System.Security.AllowPartiallyTrustedCallersAttribute")
				{
					Value = "(Present)";
				}
				else
				{
					Value = TypeName;
				}
				if (nvc.Get(Name) == null)
				{
					nvc.Add(Name, Value);
				}
			}
			try
			{
				nvc.Add("CodeBase", a.CodeBase.Replace("file:///", ""));
			}
			catch (System.NotSupportedException)
			{
				nvc.Add("CodeBase", "(not supported)");
			}
			DateTime dt = AssemblyBuildDate(a);
			if (dt == DateTime.MaxValue)
			{
				nvc.Add("BuildDate", "(unknown)");
			}
			else
			{
				nvc.Add("BuildDate", dt.ToString("yyyy-MM-dd hh:mm tt"));
			}
			try
			{
				nvc.Add("Location", a.Location);
			}
			catch (System.NotSupportedException)
			{
				nvc.Add("Location", "(not supported)");
			}
			try
			{
				if (a.GetName().Version.Major == 0 & a.GetName().Version.Minor == 0)
				{
					nvc.Add("Version", "(unknown)");
				}
				else
				{
					nvc.Add("Version", a.GetName().Version.ToString());
				}
			}
			catch (Exception)
			{
				nvc.Add("Version", "(unknown)");
			}
			nvc.Add("FullName", a.FullName);
			return nvc;
		}

		private string RegistryHklmValue(string KeyName, string SubKeyRef)
		{
			RegistryKey rk;
			try
			{
				rk = Registry.LocalMachine.OpenSubKey(KeyName);
				return ((string)(rk.GetValue(SubKeyRef, "")));
			}
			catch (Exception)
			{
				return "";
			}
		}

		private void ShowSysInfo()
		{
			string strSysInfoPath = "";
			strSysInfoPath = RegistryHklmValue("SOFTWARE\\Microsoft\\Shared Tools Location", "MSINFO");
			if (strSysInfoPath == "")
			{
				strSysInfoPath = RegistryHklmValue("SOFTWARE\\Microsoft\\Shared Tools\\MSINFO", "PATH");
			}
			if (strSysInfoPath == "")
			{
				MessageBox.Show("System Information is unavailable at this time." + Environment.NewLine + Environment.NewLine + "(couldn't find Path for Microsoft System Information Tool in the registry.)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}
			try
			{
				Process.Start(strSysInfoPath);
			}
			catch (Exception)
			{
				MessageBox.Show("System Information is unavailable at this time." + Environment.NewLine + Environment.NewLine + "(couldn't launch '" + strSysInfoPath + "')", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
			}
		}

		private void Populate(ListView lvw, string Key, string Value)
		{
			if (Value == "")
			{
				return;
			}
			System.Windows.Forms.ListViewItem lvi = new System.Windows.Forms.ListViewItem();
			lvi.Text = Key;
			lvi.SubItems.Add(Value);
			lvw.Items.Add(lvi);
		}

		private void PopulateAppInfo()
		{
			System.AppDomain d = System.AppDomain.CurrentDomain;
			Populate(AppInfoListView, "Application Name", d.SetupInformation.ApplicationName);
			Populate(AppInfoListView, "Application Base", d.SetupInformation.ApplicationBase);
			Populate(AppInfoListView, "Cache Path", d.SetupInformation.CachePath);
			Populate(AppInfoListView, "Configuration File", d.SetupInformation.ConfigurationFile);
			Populate(AppInfoListView, "Dynamic Base", d.SetupInformation.DynamicBase);
			Populate(AppInfoListView, "Friendly Name", d.FriendlyName);
			Populate(AppInfoListView, "License File", d.SetupInformation.LicenseFile);
			Populate(AppInfoListView, "Private Bin Path", d.SetupInformation.PrivateBinPath);
			Populate(AppInfoListView, "Shadow Copy Directories", d.SetupInformation.ShadowCopyDirectories);
			Populate(AppInfoListView, " ", " ");
			Populate(AppInfoListView, "Entry Assembly", _strEntryAssemblyName);
			Populate(AppInfoListView, "Executing Assembly", _strExecutingAssemblyName);
			Populate(AppInfoListView, "Calling Assembly", _strCallingAssemblyName);
		}

		private void PopulateAssemblies()
		{
			foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
			{
				PopulateAssemblySummary(a);
			}
			AssemblyNamesComboBox.SelectedIndex = AssemblyNamesComboBox.FindStringExact(_strEntryAssemblyName);
		}

		private void PopulateAssemblySummary(Assembly a)
		{
			System.Collections.Specialized.NameValueCollection nvc = AssemblyAttribs(a);
			string strAssemblyName = a.GetName().Name;
			System.Windows.Forms.ListViewItem lvi = new System.Windows.Forms.ListViewItem();
			lvi.Text = strAssemblyName;
			lvi.Tag = strAssemblyName;
			if (strAssemblyName == _strCallingAssemblyName)
			{
				lvi.Text += " (calling)";
			}
			if (strAssemblyName == _strExecutingAssemblyName)
			{
				lvi.Text += " (executing)";
			}
			if (strAssemblyName == _strEntryAssemblyName)
			{
				lvi.Text += " (entry)";
			}
			lvi.SubItems.Add(nvc.Get("version"));
			lvi.SubItems.Add(nvc.Get("builddate"));
			lvi.SubItems.Add(nvc.Get("codebase"));
			AssemblyInfoListView.Items.Add(lvi);
			AssemblyNamesComboBox.Items.Add(strAssemblyName);
		}

		private string EntryAssemblyAttrib(string strName)
		{
			if (_EntryAssemblyAttribCollection[strName] == "")
			{
				return "<Assembly: Assembly" + strName + "(\"\")>";
			}
			else
			{
				return _EntryAssemblyAttribCollection[strName].ToString();
			}
		}

		private void PopulateLabels()
		{
			_EntryAssemblyAttribCollection = AssemblyAttribs(_EntryAssembly);
			if (this.Owner == null)
			{
				ImagePictureBox.Visible = false;
				AppTitleLabel.Left = AppCopyrightLabel.Left;
				AppDescriptionLabel.Left = AppCopyrightLabel.Left;
			}
			else
			{
				this.Icon = this.Owner.Icon;
				ImagePictureBox.Image = this.Icon.ToBitmap();
			}
			this.Text = ReplaceTokens(this.Text);
			AppTitleLabel.Text = ReplaceTokens(AppTitleLabel.Text);
			if (AppDescriptionLabel.Visible)
			{
				AppDescriptionLabel.Text = ReplaceTokens(AppDescriptionLabel.Text);
			}
			if (AppCopyrightLabel.Visible)
			{
				AppCopyrightLabel.Text = ReplaceTokens(AppCopyrightLabel.Text);
			}
			if (AppVersionLabel.Visible)
			{
				AppVersionLabel.Text = ReplaceTokens(AppVersionLabel.Text);
			}
			if (AppDateLabel.Visible)
			{
				AppDateLabel.Text = ReplaceTokens(AppDateLabel.Text);
			}
			if (MoreRichTextBox.Visible)
			{
				MoreRichTextBox.Text = ReplaceTokens(MoreRichTextBox.Text);
			}
		}

		private string ReplaceTokens(string s)
		{
			s = s.Replace("%title%", EntryAssemblyAttrib("title"));
			s = s.Replace("%copyright%", EntryAssemblyAttrib("copyright"));
			s = s.Replace("%description%", EntryAssemblyAttrib("description"));
			s = s.Replace("%company%", EntryAssemblyAttrib("company"));
			s = s.Replace("%product%", EntryAssemblyAttrib("product"));
			s = s.Replace("%trademark%", EntryAssemblyAttrib("trademark"));
			s = s.Replace("%year%", DateTime.Now.Year.ToString());
			s = s.Replace("%version%", EntryAssemblyAttrib("version"));
			s = s.Replace("%builddate%", EntryAssemblyAttrib("builddate"));
			return s;
		}

		private void PopulateAssemblyDetails(System.Reflection.Assembly a, ListView lvw)
		{
			lvw.Items.Clear();
			Populate(lvw, "Image Runtime Version", a.ImageRuntimeVersion);
			Populate(lvw, "Loaded from GAC", a.GlobalAssemblyCache.ToString());
			System.Collections.Specialized.NameValueCollection nvc = AssemblyAttribs(a);

			foreach (string strKey in nvc)
			{
				Populate(lvw, strKey, nvc.Get(strKey));
			}
		}

		private Assembly MatchAssemblyByName(string AssemblyName)
		{
			foreach(Assembly a in AppDomain.CurrentDomain.GetAssemblies())
			{
				if (a.GetName().Name == AssemblyName)
				{
					return a;

				}
			}
			return null;
		}

		private void AboutBox_Load(object sender, System.EventArgs e)
		{
			if (_EntryAssembly == null)
			{
				_EntryAssembly = Assembly.GetEntryAssembly();
			}
			if (_EntryAssembly == null)
			{
				_EntryAssembly = Assembly.GetExecutingAssembly();
			}
			_strExecutingAssemblyName = Assembly.GetExecutingAssembly().GetName().Name;
			_strCallingAssemblyName = Assembly.GetCallingAssembly().GetName().Name;
			try
			{
				_strEntryAssemblyName = Assembly.GetEntryAssembly().GetName().Name;
			}
			catch (Exception)
			{
			}
			_intMinWindowHeight = AppCopyrightLabel.Top + AppCopyrightLabel.Height + OKButton.Height + 30;
			this.TabPanelDetails.Visible = false;
			if (!(MoreRichTextBox.Visible))
			{
				this.Height = this.Height - MoreRichTextBox.Height;
			}
		}

		private void AboutBox_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
		{
			if (!(_IsPainted))
			{
				_IsPainted = true;
				Application.DoEvents();
				Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
				PopulateLabels();
				Cursor.Current = System.Windows.Forms.Cursors.Default;
			}
		}

		private void DetailsButton_Click(object sender, System.EventArgs e)
		{
			Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
			DetailsButton.Visible = false;
			this.SuspendLayout();
			this.MaximizeBox = true;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
			this.Size = new Size(580, this.Size.Height + 200);
			MoreRichTextBox.Visible = false;
			TabPanelDetails.Visible = true;
			SysInfoButton.Visible = true;
			PopulateAssemblies();
			PopulateAppInfo();
			this.CenterToParent();
			this.ResumeLayout();
			Cursor.Current = System.Windows.Forms.Cursors.Default;
		}

		private void SysInfoButton_Click(object sender, System.EventArgs e)
		{
			ShowSysInfo();
		}

		private void AssemblyInfoListView_DoubleClick(object sender, System.EventArgs e)
		{
			string strAssemblyName;
			if (AssemblyInfoListView.SelectedItems.Count > 0)
			{
				strAssemblyName = Convert.ToString(AssemblyInfoListView.SelectedItems[0].Tag);
				AssemblyNamesComboBox.SelectedIndex = AssemblyNamesComboBox.FindStringExact(strAssemblyName);
				this.TabPanelDetails.SelectedTab = this.TabPageAssemblyDetails;
			}
		}

		private void AssemblyNamesComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string strAssemblyName = Convert.ToString(AssemblyNamesComboBox.SelectedItem);
			PopulateAssemblyDetails(MatchAssemblyByName(strAssemblyName), AssemblyDetailsListView);
		}

		private void AssemblyInfoListView_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e)
		{
			bAscending = !bAscending;

			int intTargetCol = e.Column + 1;
			if (!(AssemblyInfoListView.Tag == null))
			{
				if (Math.Abs(Convert.ToInt32(AssemblyInfoListView.Tag)) == intTargetCol)
				{
					intTargetCol = -Convert.ToInt32(AssemblyInfoListView.Tag);
				}
			}
			AssemblyInfoListView.Tag = intTargetCol;
			AssemblyInfoListView.ListViewItemSorter = new ListViewItemComparer(intTargetCol, bAscending);
		}

		private void MoreRichTextBox_LinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e)
		{
			try
			{
				Process.Start(e.LinkText);
			}
			catch (Exception)
			{
			}
		}
		class ListViewItemComparer : IComparer
		{
			private int _intCol;
			private bool _IsAscending = true;

			public ListViewItemComparer()
			{
				_intCol = 0;
				_IsAscending = true;
			}

			public ListViewItemComparer(int column, bool ascending)
			{
				if (column < 0)
				{
					_IsAscending = false;
				}
				else
				{
					_IsAscending = ascending;
				}
				_intCol = Math.Abs(column) - 1;
			}

			public int Compare(object x, object y)
			{
				int intResult = String.Compare(((ListViewItem)(x)).SubItems[_intCol].Text, ((ListViewItem)(y)).SubItems[_intCol].Text);
				if (_IsAscending)
				{
					return intResult;
				}
				else
				{
					return -intResult;
				}
			}
		}

		private void TabPanelDetails_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if (TabPanelDetails.SelectedTab == this.TabPageAssemblyDetails)
			{
				AssemblyNamesComboBox.Focus();
			}
		}

		#region Assembly Attibute Accessors

		public string AssemblyTitle
		{
			get
			{
				// Get all Title attributes on this assembly
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
				// If there is at least one Title attribute
				if (attributes.Length > 0)
				{
					// Select the first one
					AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
					// If it is not an empty string, return it
					if (titleAttribute.Title != "")
						return titleAttribute.Title;
				}
				// If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name
				return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
			}
		}

		public string AssemblyVersion
		{
			get
			{
				return Assembly.GetExecutingAssembly().GetName().Version.ToString();
			}
		}

		public string AssemblyDescription
		{
			get
			{
				// Get all Description attributes on this assembly
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
				// If there aren't any Description attributes, return an empty string
				if (attributes.Length == 0)
					return "";
				// If there is a Description attribute, return its value
				return ((AssemblyDescriptionAttribute)attributes[0]).Description;
			}
		}

		public string AssemblyProduct
		{
			get
			{
				// Get all Product attributes on this assembly
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
				// If there aren't any Product attributes, return an empty string
				if (attributes.Length == 0)
					return "";
				// If there is a Product attribute, return its value
				return ((AssemblyProductAttribute)attributes[0]).Product;
			}
		}

		public string AssemblyCopyright
		{
			get
			{
				// Get all Copyright attributes on this assembly
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
				// If there aren't any Copyright attributes, return an empty string
				if (attributes.Length == 0)
					return "";
				// If there is a Copyright attribute, return its value
				return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
			}
		}

		public string AssemblyCompany
		{
			get
			{
				// Get all Company attributes on this assembly
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
				// If there aren't any Company attributes, return an empty string
				if (attributes.Length == 0)
					return "";
				// If there is a Company attribute, return its value
				return ((AssemblyCompanyAttribute)attributes[0]).Company;
			}
		}
		#endregion

		private void OKButton_Click(object sender, EventArgs e)
		{
			this.Close();
		}

	}
}